package com.rocksdata.mc.entity;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

public class UnreadCache implements Serializable {
    private Map<String, List<String>> unreadMap;

    public Map<String, List<String>> getUnreadMap() {
        return unreadMap;
    }

    public void setUnreadMap(Map<String, List<String>> unreadMap) {
        this.unreadMap = unreadMap;
    }

    public int getUnreadCount (String appId) {
        if (unreadMap == null || unreadMap.size() == 0)
            return 0;
        List<String> codes = unreadMap.get(appId);
        if (codes == null)
            return 0;
        return codes.size();
    }

    public int getTotalUnreadCount () {
        if (unreadMap == null || unreadMap.size() == 0)
            return 0;
        int result = 0;
        for (String key: unreadMap.keySet()) {
            List<String> codes = unreadMap.get(key);
            if (codes != null) {
                result += codes.size();
            }
        }
        return result;
    }
}
